// Copyright (c) 2025, Your Name and contributors
// For license information, please see license.txt

frappe.ui.form.on('MaxKey SSO Settings', {
    refresh: function(frm) {
        // 添加测试连接按钮
        frm.add_custom_button(__('测试连接'), function() {
            frappe.call({
                method: 'erpnext_maxkey_sso.erpnext_maxkey_sso.utils.oauth_utils.test_connection',
                callback: function(r) {
                    if (r.message) {
                        frappe.msgprint(__('成功连接到 MaxKey 服务器'));
                    } else {
                        frappe.msgprint(__('无法连接到 MaxKey 服务器，请检查配置'));
                    }
                }
            });
        });
    }
});
